package cn.zf.spring5.service;

import cn.zf.spring5.dao.UserDao;
import cn.zf.spring5.dao.UserDaoImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


//注解里面value值可以不屑
//默认值是类名称，首字母小写
//@Component //<bean id = "" class= ""/>

@Service
public class UserService {
    //定义dao类型属性
    //不需要添加set方法
    //添加注入属性注解

//    @Autowired
//    @Qualifier(value = "userDaoImpl1")
    @Resource(name = "userDaoImpl1")
    private UserDao userDao;

    @Value(value = "abc")
    private String name;

    public void add(){
        System.out.println(name);
        System.out.println("Service add............");
        userDao.add();
    }
}
